package lev01_beginnerClass.class07_linkedLIst;

public class L02_ReverseDoubleLinkedList {
    public static void main(String[] args) {

    }

    public static  DoubleNode reverseDoubleLinkedList(DoubleNode head){
        if(head == null || head.next == null){
            return  head;

        }
        //构建辅助节点
        DoubleNode pre = null;
        DoubleNode next = null;
        while (head != null){
            next = head.next;
            head.next = pre;
            head.last = next;
            pre = head;
            head = next;
        }
        return pre;
    }

    public static class DoubleNode{
        private DoubleNode last;
        private DoubleNode next;
        int value;

        DoubleNode(int value){
            this.value = value;
        }

    }

}
